Hệ thống xếp lịch học tín chỉ cho sinh viên CNTT trên PHP & MySQL
111.120 lượt xem;
- class_time_table_view.php
- project /
1 <?php
2 // This script and data application were generated by AppGini 5.72
3 // Download AppGini for free from https://bigprof.com/appgini/download/
4
5 $currDir=dirname(__FILE__);
6 include("$currDir/defaultLang.php");
7 include("$currDir/language.php");
8 include("$currDir/lib.php");
9 @include("$currDir/hooks/class_time_table.php");
10 include("$currDir/class_time_table_dml.php");
11
12 // mm: can the current member access this page?
13 $perm=getTablePermissions('class_time_table');
14 if(!$perm[0]){
15 echo error_message($Translation['tableAccessDenied'], false);
16 echo '<script>setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
17 exit;
18 }
19
20 $x = new DataList;
21 $x->TableName = "class_time_table";
22
23 // Fields that can be displayed in the table view
24 $x->QueryFieldsTV = array(
25 "`class_time_table`.`id`" => "id",
26 "`class_time_table`.`day`" => "day",
27 "TIME_FORMAT(`class_time_table`.`time_start`, '%r')" => "time_start",
28 "TIME_FORMAT(`class_time_table`.`time_end`, '%r')" => "time_end",
29 "`class_time_table`.`unit_code`" => "unit_code",
30 "`class_time_table`.`venue`" => "venue",
31 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
32 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
33 "`class_time_table`.`year_of_study`" => "year_of_study"
34 );
35 // mapping incoming sort by requests to actual query fields
36 $x->SortFields = array(
37 1 => '`class_time_table`.`id`',
38 2 => 2,
39 3 => '`class_time_table`.`time_start`',
40 4 => '`class_time_table`.`time_end`',
41 5 => 5,
42 6 => 6,
43 7 => '`schools1`.`name`',
44 8 => '`departments1`.`name`',
45 9 => 9
46 );
47
48 // Fields that can be displayed in the csv file
49 $x->QueryFieldsCSV = array(
50 "`class_time_table`.`id`" => "id",
51 "`class_time_table`.`day`" => "day",
52 "TIME_FORMAT(`class_time_table`.`time_start`, '%r')" => "time_start",
53 "TIME_FORMAT(`class_time_table`.`time_end`, '%r')" => "time_end",
54 "`class_time_table`.`unit_code`" => "unit_code",
55 "`class_time_table`.`venue`" => "venue",
56 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
57 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
58 "`class_time_table`.`year_of_study`" => "year_of_study"
59 );
60 // Fields that can be filtered
61 $x->QueryFieldsFilters = array(
62 "`class_time_table`.`id`" => "ID",
63 "`class_time_table`.`day`" => "Day",
64 "`class_time_table`.`time_start`" => " Time Start",
65 "`class_time_table`.`time_end`" => "Time End",
66 "`class_time_table`.`unit_code`" => "Unit code",
67 "`class_time_table`.`venue`" => "Venue",
68 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "School",
69 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "Department",
70 "`class_time_table`.`year_of_study`" => "Year of study"
71 );
72
73 // Fields that can be quick searched
74 $x->QueryFieldsQS = array(
75 "`class_time_table`.`id`" => "id",
76 "`class_time_table`.`day`" => "day",
77 "TIME_FORMAT(`class_time_table`.`time_start`, '%r')" => "time_start",
78 "TIME_FORMAT(`class_time_table`.`time_end`, '%r')" => "time_end",
79 "`class_time_table`.`unit_code`" => "unit_code",
80 "`class_time_table`.`venue`" => "venue",
81 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
82 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
83 "`class_time_table`.`year_of_study`" => "year_of_study"
84 );
85
86 // Lookup fields that can be used as filterers
87 $x->filterers = array( 'school' => 'School', 'department' => 'Department');
88
89 $x->QueryFrom = "`class_time_table` LEFT JOIN `schools` as schools1 ON `schools1`.`id`=`class_time_table`.`school` LEFT JOIN `departments` as departments1 ON `departments1`.`id`=`class_time_table`.`department` ";
90 $x->QueryWhere = '';
91 $x->QueryOrder = '';
92
93 $x->AllowSelection = 1;
94 $x->HideTableView = ($perm[2]==0 ? 1 : 0);
95 $x->AllowDelete = $perm[4];
96 $x->AllowMassDelete = true;
97 $x->AllowInsert = $perm[1];
98 $x->AllowUpdate = $perm[3];
99 $x->SeparateDV = 1;
100 $x->AllowDeleteOfParents = 0;
101 $x->AllowFilters = 1;
102 $x->AllowSavingFilters = 1;
103 $x->AllowSorting = 1;
104 $x->AllowNavigation = 1;
105 $x->AllowPrinting = 1;
106 $x->AllowCSV = 1;
107 $x->RecordsPerPage = 100;
108 $x->QuickSearch = 1;
109 $x->QuickSearchText = $Translation["quick search"];
110 $x->ScriptFileName = "class_time_table_view.php";
111 $x->RedirectAfterInsert = "class_time_table_view.php?SelectedID=#ID#";
112 $x->TableTitle = "Lịch học";
113 $x->TableIcon = "resources/table_icons/blackboard_drawing.png";
114 $x->PrimaryKey = "`class_time_table`.`id`";
115
116 $x->ColWidth = array( 150, 150, 150, 150, 150, 150, 150, 150);
117 $x->ColCaption = array("Ngày", " Thời gian bắt đầu", "Kết thúc", "Mã môn", "Địa điểm", "Lớp học", "Môn học", "Học kỳ");
118 $x->ColFieldName = array('day', 'time_start', 'time_end', 'unit_code', 'venue', 'school', 'department', 'year_of_study');
119 $x->ColNumber = array(2, 3, 4, 5, 6, 7, 8, 9);
120
121 // template paths below are based on the app main directory
122 $x->Template = 'templates/class_time_table_templateTV.html';
123 $x->SelectedTemplate = 'templates/class_time_table_templateTVS.html';
124 $x->TemplateDV = 'templates/class_time_table_templateDV.html';
125 $x->TemplateDVP = 'templates/class_time_table_templateDVP.html';
126
127 $x->ShowTableHeader = 1;
128 $x->TVClasses = "";
129 $x->DVClasses = "";
130 $x->HighlightColor = '#FFF0C2';
131
132 // mm: build the query based on current member's permissions
133 $DisplayRecords = $_REQUEST['DisplayRecords'];
134 if(!in_array($DisplayRecords, array('user', 'group'))){ $DisplayRecords = 'all'; }
135 if($perm[2]==1 || ($perm[2]>1 && $DisplayRecords=='user' && !$_REQUEST['NoFilter_x'])){ // view owner only
136 $x->QueryFrom.=', membership_userrecords';
137 $x->QueryWhere="where `class_time_table`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='class_time_table' and lcase(membership_userrecords.memberID)='".getLoggedMemberID()."'";
138 }elseif($perm[2]==2 || ($perm[2]>2 && $DisplayRecords=='group' && !$_REQUEST['NoFilter_x'])){ // view group only
139 $x->QueryFrom.=', membership_userrecords';
140 $x->QueryWhere="where `class_time_table`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='class_time_table' and membership_userrecords.groupID='".getLoggedGroupID()."'";
141 }elseif($perm[2]==3){ // view all
142 // no further action
143 }elseif($perm[2]==0){ // view none
144 $x->QueryFields = array("Not enough permissions" => "NEP");
145 $x->QueryFrom = '`class_time_table`';
146 $x->QueryWhere = '';
147 $x->DefaultSortField = '';
148 }
149 // hook: class_time_table_init
150 $render=TRUE;
151 if(function_exists('class_time_table_init')){
152 $args=array();
153 $render=class_time_table_init($x, getMemberInfo(), $args);
154 }
155
156 if($render) $x->Render();
157
158 // hook: class_time_table_header
159 $headerCode='';
160 if(function_exists('class_time_table_header')){
161 $args=array();
162 $headerCode=class_time_table_header($x->ContentType, getMemberInfo(), $args);
163 }
164 if(!$headerCode){
165 include_once("$currDir/header.php");
166 }else{
167 ob_start(); include_once("$currDir/header.php"); $dHeader=ob_get_contents(); ob_end_clean();
168 echo str_replace('<%%HEADER%%>', $dHeader, $headerCode);
169 }
170
171 echo $x->HTML;
172 // hook: class_time_table_footer
173 $footerCode='';
174 if(function_exists('class_time_table_footer')){
175 $args=array();
176 $footerCode=class_time_table_footer($x->ContentType, getMemberInfo(), $args);
177 }
178 if(!$footerCode){
179 include_once("$currDir/footer.php");
180 }else{
181 ob_start(); include_once("$currDir/footer.php"); $dFooter=ob_get_contents(); ob_end_clean();
182 echo str_replace('<%%FOOTER%%>', $dFooter, $footerCode);
183 }
184 ?>
2 // This script and data application were generated by AppGini 5.72
3 // Download AppGini for free from https://bigprof.com/appgini/download/
4
5 $currDir=dirname(__FILE__);
6 include("$currDir/defaultLang.php");
7 include("$currDir/language.php");
8 include("$currDir/lib.php");
9 @include("$currDir/hooks/class_time_table.php");
10 include("$currDir/class_time_table_dml.php");
11
12 // mm: can the current member access this page?
13 $perm=getTablePermissions('class_time_table');
14 if(!$perm[0]){
15 echo error_message($Translation['tableAccessDenied'], false);
16 echo '<script>setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
17 exit;
18 }
19
20 $x = new DataList;
21 $x->TableName = "class_time_table";
22
23 // Fields that can be displayed in the table view
24 $x->QueryFieldsTV = array(
25 "`class_time_table`.`id`" => "id",
26 "`class_time_table`.`day`" => "day",
27 "TIME_FORMAT(`class_time_table`.`time_start`, '%r')" => "time_start",
28 "TIME_FORMAT(`class_time_table`.`time_end`, '%r')" => "time_end",
29 "`class_time_table`.`unit_code`" => "unit_code",
30 "`class_time_table`.`venue`" => "venue",
31 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
32 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
33 "`class_time_table`.`year_of_study`" => "year_of_study"
34 );
35 // mapping incoming sort by requests to actual query fields
36 $x->SortFields = array(
37 1 => '`class_time_table`.`id`',
38 2 => 2,
39 3 => '`class_time_table`.`time_start`',
40 4 => '`class_time_table`.`time_end`',
41 5 => 5,
42 6 => 6,
43 7 => '`schools1`.`name`',
44 8 => '`departments1`.`name`',
45 9 => 9
46 );
47
48 // Fields that can be displayed in the csv file
49 $x->QueryFieldsCSV = array(
50 "`class_time_table`.`id`" => "id",
51 "`class_time_table`.`day`" => "day",
52 "TIME_FORMAT(`class_time_table`.`time_start`, '%r')" => "time_start",
53 "TIME_FORMAT(`class_time_table`.`time_end`, '%r')" => "time_end",
54 "`class_time_table`.`unit_code`" => "unit_code",
55 "`class_time_table`.`venue`" => "venue",
56 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
57 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
58 "`class_time_table`.`year_of_study`" => "year_of_study"
59 );
60 // Fields that can be filtered
61 $x->QueryFieldsFilters = array(
62 "`class_time_table`.`id`" => "ID",
63 "`class_time_table`.`day`" => "Day",
64 "`class_time_table`.`time_start`" => " Time Start",
65 "`class_time_table`.`time_end`" => "Time End",
66 "`class_time_table`.`unit_code`" => "Unit code",
67 "`class_time_table`.`venue`" => "Venue",
68 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "School",
69 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "Department",
70 "`class_time_table`.`year_of_study`" => "Year of study"
71 );
72
73 // Fields that can be quick searched
74 $x->QueryFieldsQS = array(
75 "`class_time_table`.`id`" => "id",
76 "`class_time_table`.`day`" => "day",
77 "TIME_FORMAT(`class_time_table`.`time_start`, '%r')" => "time_start",
78 "TIME_FORMAT(`class_time_table`.`time_end`, '%r')" => "time_end",
79 "`class_time_table`.`unit_code`" => "unit_code",
80 "`class_time_table`.`venue`" => "venue",
81 "IF( CHAR_LENGTH(`schools1`.`name`), CONCAT_WS('', `schools1`.`name`), '') /* School */" => "school",
82 "IF( CHAR_LENGTH(`departments1`.`name`), CONCAT_WS('', `departments1`.`name`), '') /* Department */" => "department",
83 "`class_time_table`.`year_of_study`" => "year_of_study"
84 );
85
86 // Lookup fields that can be used as filterers
87 $x->filterers = array( 'school' => 'School', 'department' => 'Department');
88
89 $x->QueryFrom = "`class_time_table` LEFT JOIN `schools` as schools1 ON `schools1`.`id`=`class_time_table`.`school` LEFT JOIN `departments` as departments1 ON `departments1`.`id`=`class_time_table`.`department` ";
90 $x->QueryWhere = '';
91 $x->QueryOrder = '';
92
93 $x->AllowSelection = 1;
94 $x->HideTableView = ($perm[2]==0 ? 1 : 0);
95 $x->AllowDelete = $perm[4];
96 $x->AllowMassDelete = true;
97 $x->AllowInsert = $perm[1];
98 $x->AllowUpdate = $perm[3];
99 $x->SeparateDV = 1;
100 $x->AllowDeleteOfParents = 0;
101 $x->AllowFilters = 1;
102 $x->AllowSavingFilters = 1;
103 $x->AllowSorting = 1;
104 $x->AllowNavigation = 1;
105 $x->AllowPrinting = 1;
106 $x->AllowCSV = 1;
107 $x->RecordsPerPage = 100;
108 $x->QuickSearch = 1;
109 $x->QuickSearchText = $Translation["quick search"];
110 $x->ScriptFileName = "class_time_table_view.php";
111 $x->RedirectAfterInsert = "class_time_table_view.php?SelectedID=#ID#";
112 $x->TableTitle = "Lịch học";
113 $x->TableIcon = "resources/table_icons/blackboard_drawing.png";
114 $x->PrimaryKey = "`class_time_table`.`id`";
115
116 $x->ColWidth = array( 150, 150, 150, 150, 150, 150, 150, 150);
117 $x->ColCaption = array("Ngày", " Thời gian bắt đầu", "Kết thúc", "Mã môn", "Địa điểm", "Lớp học", "Môn học", "Học kỳ");
118 $x->ColFieldName = array('day', 'time_start', 'time_end', 'unit_code', 'venue', 'school', 'department', 'year_of_study');
119 $x->ColNumber = array(2, 3, 4, 5, 6, 7, 8, 9);
120
121 // template paths below are based on the app main directory
122 $x->Template = 'templates/class_time_table_templateTV.html';
123 $x->SelectedTemplate = 'templates/class_time_table_templateTVS.html';
124 $x->TemplateDV = 'templates/class_time_table_templateDV.html';
125 $x->TemplateDVP = 'templates/class_time_table_templateDVP.html';
126
127 $x->ShowTableHeader = 1;
128 $x->TVClasses = "";
129 $x->DVClasses = "";
130 $x->HighlightColor = '#FFF0C2';
131
132 // mm: build the query based on current member's permissions
133 $DisplayRecords = $_REQUEST['DisplayRecords'];
134 if(!in_array($DisplayRecords, array('user', 'group'))){ $DisplayRecords = 'all'; }
135 if($perm[2]==1 || ($perm[2]>1 && $DisplayRecords=='user' && !$_REQUEST['NoFilter_x'])){ // view owner only
136 $x->QueryFrom.=', membership_userrecords';
137 $x->QueryWhere="where `class_time_table`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='class_time_table' and lcase(membership_userrecords.memberID)='".getLoggedMemberID()."'";
138 }elseif($perm[2]==2 || ($perm[2]>2 && $DisplayRecords=='group' && !$_REQUEST['NoFilter_x'])){ // view group only
139 $x->QueryFrom.=', membership_userrecords';
140 $x->QueryWhere="where `class_time_table`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='class_time_table' and membership_userrecords.groupID='".getLoggedGroupID()."'";
141 }elseif($perm[2]==3){ // view all
142 // no further action
143 }elseif($perm[2]==0){ // view none
144 $x->QueryFields = array("Not enough permissions" => "NEP");
145 $x->QueryFrom = '`class_time_table`';
146 $x->QueryWhere = '';
147 $x->DefaultSortField = '';
148 }
149 // hook: class_time_table_init
150 $render=TRUE;
151 if(function_exists('class_time_table_init')){
152 $args=array();
153 $render=class_time_table_init($x, getMemberInfo(), $args);
154 }
155
156 if($render) $x->Render();
157
158 // hook: class_time_table_header
159 $headerCode='';
160 if(function_exists('class_time_table_header')){
161 $args=array();
162 $headerCode=class_time_table_header($x->ContentType, getMemberInfo(), $args);
163 }
164 if(!$headerCode){
165 include_once("$currDir/header.php");
166 }else{
167 ob_start(); include_once("$currDir/header.php"); $dHeader=ob_get_contents(); ob_end_clean();
168 echo str_replace('<%%HEADER%%>', $dHeader, $headerCode);
169 }
170
171 echo $x->HTML;
172 // hook: class_time_table_footer
173 $footerCode='';
174 if(function_exists('class_time_table_footer')){
175 $args=array();
176 $footerCode=class_time_table_footer($x->ContentType, getMemberInfo(), $args);
177 }
178 if(!$footerCode){
179 include_once("$currDir/footer.php");
180 }else{
181 ob_start(); include_once("$currDir/footer.php"); $dFooter=ob_get_contents(); ob_end_clean();
182 echo str_replace('<%%FOOTER%%>', $dFooter, $footerCode);
183 }
184 ?>